<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2022/1/18
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common/head.jsp"%>
<html>
<head>
    <title>教师信息</title>
    <script src="../static/js/jquery-3.4.1.js"></script>
    <script>
        $(function() {
                $.ajax({
                    url:"../user/lookteacher",
                    data:{tid:${tid}},
                    type:"post",
                    dataType:"json",
                    success:function(data){
                        // alert(data.tid)
                        var str="";
                            str+=
                            "<tr><td>教师编号</td><td><input readonly type='text' id='tid' name='tid' value='"+data.tid+"'></td></tr>" +
                            "<tr><td>姓名：</td><td><input readonly  type='text' name='tname' value='"+data.tname+"'></td></tr>" +
                            "<tr><td>性别：</td><td><input  type='text' name='gender' value='"+data.gender+"'></td></tr>" +
                            "<tr> <td>密码：</td><td><input type='text' name='password' value='"+data.password+"'></td></tr>" +
                            " <tr><td colspan='2'>" +
                            "                <div align='center'>" +
                            "                <input type='submit' id='update' value='修改'>" +
                            "                <input type='reset' value='重置'>" +
                            "                </div>" +
                            "            </td></tr>"

                        $(".teachers").append(str);

                    }
            })


        })
        function update1(){
            var teacher1 = $("#updateteacher").serializeArray();
            alert(teacher1)
            $.ajax({
                url:"../user/updateteacher",
                data:teacher1,
                type:"get",
                dataType:"json",
                success:function(data) {
                    alert(data)
                    if(data){
                        alert("修改成功");
                        location.href="page/teachers"
                    }else {
                        alert("修改失败");
                        location.href="page/updateteacher?tid="+${tid};
                    }
                }
            })
            return false;
        }
    </script>
</head>
<style>
    form,table{
        margin-left: auto;
        margin-right: auto;
        margin-top: 100px;
    }
    td{
        width: 200px;
        height: 20px;
        text-align: center;

    }
</style>
<body>
<%--240,248,255--%>
<form onsubmit="return update1()" id="updateteacher" name="updateteacher">
    <table class="teachers" style="background-color: #f0f8ff;" border="1px solid red" cellspacing="0px"  >
        <caption><h2>教师信息</h2></caption>
<%--        <tr>--%>
<%--            <td>教师编号：</td>--%>
<%--            <td>姓名：</td>--%>
<%--            <td>性别：</td>--%>
<%--            <td>密码：</td>--%>
<%--            <td>操作：</td>--%>
<%--        </tr>--%>
<%--        nihao${tid}--%>
<%--        <tr>--%>
<%--            <td>lisi</td>--%>
<%--            <td>男</td>--%>
<%--            <td>123456</td>--%>
<%--            <td>--%>
<%--                <a href="">删除</a>--%>
<%--                <a href="">修改</a>--%>
<%--            </td>--%>
<%--        </tr>--%>
<%--        <input type="text" name="" value="">--%>
    </table>
</form>
<%@include file="common/foot.jsp" %>
</body>
</html>
